package com.zgis.module.bas.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 修改记录:
 * 24-09-29     zhengchaojun             首次创建
 */

/**
 * 类描述：时间工具类
 */
public class CxTime
{
    public static ThreadLocal<DateFormat> dtFmt = new ThreadLocal<DateFormat>()
    {
        protected SimpleDateFormat initialValue()
        {
            return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        }
    };

    public static Date now() throws Exception
    {
        return new Date();
    }

    public static Date parse(String strDatetime) throws Exception
    {
        return ((DateFormat) dtFmt.get()).parse(strDatetime);
    }

    public static String formatDatetime(Date date)
    {
        return ((DateFormat) dtFmt.get()).format(date);
    }

    public static String formatDatetime(Object date)
    {
        return ((DateFormat) dtFmt.get()).format(date);
    }
}
